package com.approval.approvalapp.center.adapter;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.support.v4.content.ContextCompat;
import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.approval.approvalapp.R;
import com.approval.approvalapp.bean.IndexFragmentBean;
import com.approval.approvalapp.center.acitivty.QjkgActivity;
import com.approval.approvalapp.center.bean.CenterIndexBean;
import com.approval.approvalapp.center.bean.TodayThingBean;
import com.approval.approvalapp.center.widget.RecycleNineLine;
import com.approval.approvalapp.message.MessageXqActivity;
import com.approval.approvalapp.util.view.MyMarkerView;
import com.github.mikephil.charting.charts.LineChart;
import com.github.mikephil.charting.charts.PieChart;
import com.github.mikephil.charting.components.Legend;
import com.github.mikephil.charting.components.XAxis;
import com.github.mikephil.charting.components.YAxis;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.LineData;
import com.github.mikephil.charting.data.LineDataSet;
import com.github.mikephil.charting.data.PieData;
import com.github.mikephil.charting.data.PieDataSet;
import com.github.mikephil.charting.data.PieEntry;
import com.github.mikephil.charting.formatter.PercentFormatter;
import com.github.mikephil.charting.formatter.ValueFormatter;
import com.github.mikephil.charting.highlight.Highlight;
import com.github.mikephil.charting.interfaces.datasets.IDataSet;
import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
import com.github.mikephil.charting.utils.ColorTemplate;
import com.github.mikephil.charting.utils.MPPointF;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * @author superman
 * @date 2019/5/8
 */
public class CenterIndexAdapter extends RecyclerView.Adapter {

    Dklistener dklistener;
    CenterIndexBean centerIndexBean;
    Context context;
    private final int INDEX_ONE = 0;
    private final int INDEX_TWO = 1;
    private final int INDEX_THREE = 2;
    private final int INDEX_FOUR = 3;
    private final int INDEX_FIVE = 4;
    private int zcper;
    private float hongper;
    private float huangper;

    public CenterIndexAdapter(CenterIndexBean centerIndexBean, Context context, Dklistener dklistener) {
        this.centerIndexBean = centerIndexBean;
        this.dklistener = dklistener;
        this.context = context;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        LayoutInflater mInflater = LayoutInflater.from(context);
        View view;

        switch (viewType) {
            case INDEX_ONE:
                view = mInflater.inflate(R.layout.cente_index_one, parent, false);
                return new ViewHolder1(view);
            case INDEX_TWO:
                view = mInflater.inflate(R.layout.cente_index_two, parent, false);
                return new ViewHolder2(view);
            case INDEX_THREE:
                view = mInflater.inflate(R.layout.cente_index_two, parent, false);
                return new ViewHolder3(view);
            case INDEX_FOUR:
                view = mInflater.inflate(R.layout.cente_index_four, parent, false);
                return new ViewHolder4(view);
            case INDEX_FIVE:
                view = mInflater.inflate(R.layout.cente_index_five, parent, false);
                return new ViewHolder5(view);
        }
        return null;
    }

    public CenterIndexBean getCenterIndexBean() {
        return centerIndexBean;
    }

    public void setCenterIndexBean(CenterIndexBean centerIndexBean) {
        this.centerIndexBean = centerIndexBean;
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        if (holder instanceof ViewHolder1) {
            if (centerIndexBean != null)
                ((ViewHolder1) holder).setData(centerIndexBean);
        } else if (holder instanceof ViewHolder2) {
            if (centerIndexBean != null)
                ((ViewHolder2) holder).setData(centerIndexBean);
        } else if (holder instanceof ViewHolder3) {
            if (centerIndexBean != null)
                ((ViewHolder3) holder).setData(centerIndexBean);
        } else if (holder instanceof ViewHolder4) {
            ((ViewHolder4) holder).setData(centerIndexBean);
        } else if (holder instanceof ViewHolder5) {
            ((ViewHolder5) holder).setData(centerIndexBean);

        }
    }

    @Override
    public int getItemViewType(int position) {
        if (position == 0) {
            return INDEX_ONE;
        } else if (position == 1) {
            return INDEX_TWO;
        } else if (position == 2) {
            return INDEX_THREE;
        } else if (position == 3) {
            return INDEX_FOUR;
        } else {
            return INDEX_FIVE;
        }
    }

    @Override
    public int getItemCount() {
        if (centerIndexBean == null) {
            return 0;
        } else {
            return 5;
        }
    }

    public class ViewHolder1 extends RecyclerView.ViewHolder {
        @Bind(R.id.tv_num1)
        TextView tvNum1;
        @Bind(R.id.tv_num2)
        TextView tvNum2;
        @Bind(R.id.tv_num3)
        TextView tvNum3;
        @Bind(R.id.tv_num4)
        TextView tvNum4;
        @Bind(R.id.tv_num5)
        TextView tvNum5;
        @Bind(R.id.tv_num6)
        TextView tvNum6;
        @Bind(R.id.tv_num7)
        TextView tvNum7;
        @Bind(R.id.tv_num8)
        TextView tvNum8;
        @Bind(R.id.tv_num9)
        TextView tvNum9;
        @Bind(R.id.tv_num10)
        TextView tvNum10;
        @Bind(R.id.tv_num11)
        TextView tvNum11;
        @Bind(R.id.recyclerView)
        RecyclerView recyclerView;
        @Bind(R.id.message_root)
        LinearLayout message_root;
        @Bind(R.id.more_infotv)
        TextView more_infotv;
        @Bind(R.id.ll_center)
        LinearLayout ll_center;
        @Bind(R.id.ll_window)
        LinearLayout ll_window;
        @Bind(R.id.dk_iv)
        ImageView dk_iv;
        @Bind(R.id.tv_sj)
        TextView tv_sj;
        @Bind(R.id.tv_qs)
        TextView tv_qs;

        ViewHolder1(View view) {
            super(view);
            ButterKnife.bind(this, view);
            recyclerView.setLayoutManager(new GridLayoutManager(context, 4));
        }

        public void setData(final CenterIndexBean bean) {
            if (bean.getNotice().getTitle() == null) {
                message_root.setVisibility(View.GONE);
            } else {
                message_root.setVisibility(View.VISIBLE);
                more_infotv.setText(bean.getNotice().getTitle());
                message_root.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        Intent intent = new Intent();
                        intent.putExtra("bean", bean.getNotice());
                        intent.putExtra("from", "1");
                        intent.setClass(context, MessageXqActivity.class);
                        context.startActivity(intent);
                    }
                });
            }
            final CenterIndexBean.CkrsTjBean ckrs_tj = bean.getCkrs_tj();
            int today_num = ckrs_tj.getToday_num();//办理群众今日人数
            int today_yc = ckrs_tj.getToday_yc();
            int today_total = ckrs_tj.getToday_total();

            int cyd = ckrs_tj.getCYD();
            int csd = ckrs_tj.getCSD();
            final int cqj = ckrs_tj.getCQJ();//窗口请假

            int zyd = ckrs_tj.getZYD();
            int zsd = ckrs_tj.getZSD();//中心实到
            final int zqj = ckrs_tj.getZQJ();

            ll_window.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    String text = "请假：" + cqj + "人 / 旷工：" + ckrs_tj.getCKG() + "人";
                    QjkgActivity.goInto(context, text, false);
                }
            });

            ll_center.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    String text = "请假：" + zqj + "人 / 旷工：" + ckrs_tj.getZKG() + "人";
                    QjkgActivity.goInto(context, text, true);
                }
            });

            dk_iv.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    dklistener.dk();
                }
            });

            tvNum1.setText(today_num + "");
            tvNum2.setText(today_yc + "");
            tvNum3.setText(today_total + "");
            tvNum4.setText(cyd + "");
            tvNum5.setText(csd + "");
            tvNum6.setText(cqj + "");
            tvNum7.setText(zyd + "");
            tvNum8.setText(zsd + "");
            tvNum9.setText(zqj + "");
            tvNum10.setText(ckrs_tj.getZKG() + "");
            tvNum11.setText(ckrs_tj.getCKG() + "");

            List<TodayThingBean> list = new ArrayList<>();
            list.clear();

            if (bean.isJrbjqs()){
                list.add(new TodayThingBean("今日受理", bean.getQs_jrbl_num() + ""));
                list.add(new TodayThingBean("办结", bean.getQs_jrbl_bj() + ""));
                list.add(new TodayThingBean("在办", bean.getQs_jrbl_zb() + ""));
                list.add(new TodayThingBean("可网办率", bean.getQs_jrbl_wbl() + "%"));
                list.add(new TodayThingBean("不予受理", bean.getQs_jrbl_bybl() + ""));
                list.add(new TodayThingBean("黄牌", bean.getQs_jrbl_hp() + ""));
                list.add(new TodayThingBean("红牌", bean.getQs_jrbl_rp() + ""));
                list.add(new TodayThingBean("实际网办率", bean.getQs_jrbl_sjwzb() + "%"));
            }else {
                list.add(new TodayThingBean("今日受理", bean.getJrbl_num() + ""));
                list.add(new TodayThingBean("办结", bean.getJrbl_bj() + ""));
                list.add(new TodayThingBean("在办", bean.getJrbl_zb() + ""));
                list.add(new TodayThingBean("可网办率", bean.getJrbl_wbl() + "%"));
                list.add(new TodayThingBean("不予受理", bean.getJrbl_bybl() + ""));
                list.add(new TodayThingBean("黄牌", bean.getJrbl_hp() + ""));
                list.add(new TodayThingBean("红牌", bean.getJrbl_rp() + ""));
                list.add(new TodayThingBean("实际网办率", bean.getJrbl_sjwzb() + "%"));
            }

            TodayThingAdapter adapter = new TodayThingAdapter(list, context);
            recyclerView.setAdapter(adapter);

            if (bean.isJrbjqs()) {
                tv_qs.setBackgroundResource(R.drawable.shape1076ff);
                tv_qs.setTextColor(Color.parseColor("#ffffff"));
                tv_sj.setBackgroundResource(R.drawable.shapef5);
                tv_sj.setTextColor(Color.parseColor("#FF7D8198"));
                adapter.setIsqs(true);
            } else {
                tv_qs.setBackgroundResource(R.drawable.shapef5);
                tv_qs.setTextColor(Color.parseColor("#FF7D8198"));
                tv_sj.setBackgroundResource(R.drawable.shape1076ff);
                tv_sj.setTextColor(Color.parseColor("#ffffff"));
                adapter.setIsqs(false);
            }

            tv_sj.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    bean.setJrbjqs(false);
                    notifyItemChanged(0);
                }
            });

            tv_qs.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    bean.setJrbjqs(true);
                    notifyItemChanged(0);
                }
            });
        }

    }

    public class ViewHolder2 extends RecyclerView.ViewHolder {
        @Bind(R.id.recyclerView)
        RecyclerView recyclerView;
        @Bind(R.id.tv_title)
        TextView tvTitle;

        ViewHolder2(View view) {
            super(view);
            ButterKnife.bind(this, view);
            recyclerView.setLayoutManager(new GridLayoutManager(context, 3));
            recyclerView.addItemDecoration(new RecycleNineLine(context));
            tvTitle.setText("常用功能");
        }

        public void setData(CenterIndexBean bean) {

            List<TodayThingBean> list = new ArrayList<>();
//            list.add(new TodayThingBean("请假申请", 0, R.drawable.icon_leave));
//            list.add(new TodayThingBean("请假审批", bean.getQjsp_num(), R.drawable.icon_leaveapprove));
//            list.add(new TodayThingBean("物资申请", 0, R.drawable.icon_material));
//            list.add(new TodayThingBean("物资审批", bean.getWzsp_num(), R.drawable.icon_materialapprove));
//            list.add(new TodayThingBean("会议室申请", 0, R.drawable.icon_meeting));
//            list.add(new TodayThingBean("会议审批", bean.getHysp_num(), R.drawable.icon_meetingapprove));
//            list.add(new TodayThingBean("建议回复", bean.getJyhf_num(), R.drawable.icon_replysuggest));
//            list.add(new TodayThingBean("重点任务", 0, R.drawable.icon_keytask));

            List<CenterIndexBean.Role> role = bean.getRole();
            for (int i = 0; i < role.size(); i++) {

                if (role.get(i).getId().equals("1")) {
                    //中心请假审批
                    list.add(new TodayThingBean(role.get(i).getId(), role.get(i).getName(), bean.getZx_qjsp_num(), R.drawable.icon_leaveapprove));
                }

                if (role.get(i).getId().equals("2")) {
                    //窗口请假审批
                    list.add(new TodayThingBean(role.get(i).getId(), role.get(i).getName(), bean.getQjsp_num(), R.drawable.icon_leaveapprove));
                }

                if (role.get(i).getId().equals("3")) {
                    //物资审批初审
                    list.add(new TodayThingBean(role.get(i).getId(), role.get(i).getName(), bean.getWzsp_num()
                            , R.drawable.icon_materialapprove));
                }

                if (role.get(i).getId().equals("4")) {
                    //物资审批终审
                    list.add(new TodayThingBean(role.get(i).getId(), role.get(i).getName(), bean.getWzsp_num()
                            , R.drawable.icon_materialapprove));
                }

                if (role.get(i).getId().equals("5")) {
                    //会议室审批
                    list.add(new TodayThingBean(role.get(i).getId(), role.get(i).getName(), bean.getHysp_num()
                            , R.drawable.icon_meetingapprove));
                }

                if (role.get(i).getId().equals("6")) {
                    //请假申请
                    list.add(new TodayThingBean(role.get(i).getId(), role.get(i).getName(), 0, R.drawable.icon_leave));
                }

                if (role.get(i).getId().equals("7")) {
                    //物资领用
                    list.add(new TodayThingBean(role.get(i).getId(), role.get(i).getName(), 0, R.drawable.icon_material));
                }

                if (role.get(i).getId().equals("8")) {
                    //会议室申请
                    list.add(new TodayThingBean(role.get(i).getId(), role.get(i).getName(), 0
                            , R.drawable.icon_meeting));
                }

                if (role.get(i).getId().equals("9")) {
                    //重点任务
                    list.add(new TodayThingBean(role.get(i).getId(), role.get(i).getName(), 0
                            , R.drawable.icon_keytask));
                }


                if (role.get(i).getId().equals("10")) {
                    //意见回复
                    list.add(new TodayThingBean(role.get(i).getId(), role.get(i).getName(), bean.getJyhf_num()
                            , R.drawable.icon_replysuggest));
                }

                if (role.get(i).getId().equals("11")) {
                    //意见回复
                    list.add(new TodayThingBean(role.get(i).getId(), role.get(i).getName(), bean.getYcxz_num()
                            , R.drawable.icon_revise));
                }

                if (role.get(i).getId().equals("12")) {
                    //意见回复
                    list.add(new TodayThingBean(role.get(i).getId(), role.get(i).getName(), 0
                            , R.drawable.icon_inform));
                }

            }


            CenterCardAdapter adapter = new CenterCardAdapter(list, context);
            recyclerView.setAdapter(adapter);
        }


    }

    public class ViewHolder3 extends RecyclerView.ViewHolder {
        @Bind(R.id.recyclerView)
        RecyclerView recyclerView;
        @Bind(R.id.tv_title)
        TextView tvTitle;

        ViewHolder3(View view) {
            super(view);
            ButterKnife.bind(this, view);
            recyclerView.setLayoutManager(new GridLayoutManager(context, 3));
            recyclerView.addItemDecoration(new RecycleNineLine(context));
            tvTitle.setText("数据统计");
        }

        public void setData(CenterIndexBean bean) {

            List<TodayThingBean> list = new ArrayList<>();
            list.add(new TodayThingBean("省级大厅统计", 0, R.drawable.icon_hallstatis));
            list.add(new TodayThingBean("事项统计", 0, R.drawable.icon_itemstatis));
            list.add(new TodayThingBean("月度评价", 0, R.drawable.icon_evaluatem));
            list.add(new TodayThingBean("办件效率统计", 0, R.drawable.icon_efficiencystatis));
            list.add(new TodayThingBean("咨询投诉统计", 0, R.drawable.icon_complainstatis));
            list.add(new TodayThingBean("办件统计", 0, R.drawable.icon_workstatis));

            CenterCardAdapter adapter = new CenterCardAdapter(list, context);
            recyclerView.setAdapter(adapter);
        }


    }

    protected String[] mParties = new String[]{
            "好评", "中评", "差评"
    };

    public static final int[] VORDIPLOM_COLORS1 = {
            Color.parseColor("#4071FF"), Color.parseColor("#F8AF35"), Color.parseColor("#DE463A")
    };

    public class ViewHolder4 extends RecyclerView.ViewHolder {

        @Bind(R.id.tv_bad)
        TextView tvBad;
        @Bind(R.id.tv_color)
        TextView tvColor;
        @Bind(R.id.pieChart)
        PieChart pieChart;
        @Bind(R.id.tv_comment_type)
        TextView tvCommentType;
        @Bind(R.id.tv_comment_num)
        TextView tvCommentNum;
        @Bind(R.id.tv_comment_pertype)
        TextView tvCommentPertype;
        @Bind(R.id.tv_comment_per)
        TextView tvCommentPer;
        @Bind(R.id.tv_comment_type1)
        TextView tv_comment_type1;
        @Bind(R.id.tv_comment_num1)
        TextView tv_comment_num1;
        @Bind(R.id.rl_ll2)
        LinearLayout rl_ll2;
        @Bind(R.id.rl_ll1)
        LinearLayout rl_ll1;

        @Bind(R.id.piecolortv)
        TextView piecolortv;
        @Bind(R.id.pjmctv)
        TextView pjmctv;
        @Bind(R.id.pjnumtv)
        TextView pjnumtv;
        @Bind(R.id.tv_sj)
        TextView tv_sj;
        @Bind(R.id.tv_qs)
        TextView tv_qs;
        @Bind(R.id.lineChart)
        LineChart lineChart;

        public ViewHolder4(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }

        public void setData(final CenterIndexBean bean) {

            tv_sj.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    bean.setQs(false);
                    notifyItemChanged(3);
                }
            });

            tv_qs.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    bean.setQs(true);
                    notifyItemChanged(3);
                }
            });

//            initPieChart(bean);



            if (bean.isQs()) {
                tv_qs.setBackgroundResource(R.drawable.shape1076ff);
                tv_qs.setTextColor(Color.parseColor("#ffffff"));
                tv_sj.setBackgroundResource(R.drawable.shapef5);
                tv_sj.setTextColor(Color.parseColor("#FF7D8198"));
                initLineChart(lineChart,bean.getQs_wbl());
                setLineData1(bean.getQs_wbl());
            } else {
                tv_qs.setBackgroundResource(R.drawable.shapef5);
                tv_qs.setTextColor(Color.parseColor("#FF7D8198"));
                tv_sj.setBackgroundResource(R.drawable.shape1076ff);
                tv_sj.setTextColor(Color.parseColor("#ffffff"));
                initLineChart2(lineChart,bean.getSj_wbl());
                setLineData1(bean.getSj_wbl());
            }


        }

//        private Boolean isInCk = true;//当前状态是点击好坏率还是红黄牌

        private void initPieChart(final CenterIndexBean centerIndexBean) {

            pieChart.setUsePercentValues(true);
            pieChart.getDescription().setEnabled(false);
            pieChart.setExtraOffsets(0, 0, 0, 0);
            pieChart.setCenterText("");//中间的文字
            pieChart.setDrawHoleEnabled(true);//中间的洞
            pieChart.setHoleColor(Color.WHITE);
            pieChart.setTransparentCircleColor(Color.WHITE);
            pieChart.setTransparentCircleAlpha(110);
            pieChart.setHoleRadius(78f);
            pieChart.setTransparentCircleRadius(61f);
            pieChart.setDrawCenterText(true);//是否显示中间文字
            pieChart.setRotationAngle(0);
            pieChart.setDrawSliceText(false);//是否显示文字
            pieChart.setRotationEnabled(true);
            pieChart.setHighlightPerTapEnabled(true);
            pieChart.setOnChartValueSelectedListener(new OnChartValueSelectedListener() {
                @Override
                public void onValueSelected(Entry e, Highlight h) {

                    int x = (int) h.getX();

                    if (centerIndexBean.isIshhl()) {
                        //好评率
                        if (x == 0) {
                            tvCommentPer.setText(centerIndexBean.getHhv().getHp().getXs() + "");
                            tvCommentType.setText("好评数");
                            tvCommentPertype.setText("好评率");
                            tvCommentPer.setTextColor(Color.parseColor("#4071FF"));
                            tvCommentNum.setText(centerIndexBean.getHhv().getHp().getNum() + "");

                            piecolortv.setText(centerIndexBean.getHhv().getHp().getXs());
                            piecolortv.setTextColor(Color.parseColor("#4071FF"));
                            pjmctv.setText("好评");
                            pjnumtv.setText(centerIndexBean.getHhv().getHp().getNum() + "");
                        } else if (x == 1) {
                            tvCommentPer.setText(centerIndexBean.getHhv().getZp().getXs() + "");
                            tvCommentType.setText("中评数");
                            tvCommentPertype.setText("中评率");
                            tvCommentPer.setTextColor(Color.parseColor("#F8AF35"));
                            tvCommentNum.setText(centerIndexBean.getHhv().getZp().getNum() + "");

                            piecolortv.setText(centerIndexBean.getHhv().getZp().getXs());
                            piecolortv.setTextColor(Color.parseColor("#F8AF35"));
                            pjmctv.setText("中评");
                            pjnumtv.setText(centerIndexBean.getHhv().getZp().getNum() + "");
                        } else {
                            tvCommentPer.setText(centerIndexBean.getHhv().getCp().getXs() + "");
                            tvCommentType.setText("差评数");
                            tvCommentPertype.setText("差评率");
                            tvCommentPer.setTextColor(Color.parseColor("#DE463A"));
                            tvCommentNum.setText(centerIndexBean.getHhv().getCp().getNum() + "");

                            piecolortv.setText(centerIndexBean.getHhv().getCp().getXs());
                            piecolortv.setTextColor(Color.parseColor("#DE463A"));
                            pjmctv.setText("差评");
                            pjnumtv.setText(centerIndexBean.getHhv().getCp().getNum() + "");
                        }
                    } else {
                        //红黄牌
                        if (x == 0) {
                            tv_comment_num1.setText(centerIndexBean.getHhp().getZc() + "");
                            tv_comment_type1.setText("正常数");

                            piecolortv.setText(zcper + "%");
                            piecolortv.setTextColor(Color.parseColor("#4071FF"));
                            pjmctv.setText("正常");
                            pjnumtv.setText(centerIndexBean.getHhp().getZc());

                        } else if (x == 1) {
                            tv_comment_num1.setText(centerIndexBean.getHhp().getHp() + "");
                            tv_comment_type1.setText("黄牌数");

                            piecolortv.setText(huangper + "%");
                            piecolortv.setTextColor(Color.parseColor("#F8AF35"));
                            pjmctv.setText("黄牌");
                            pjnumtv.setText(centerIndexBean.getHhp().getHp());
                        } else {
                            tv_comment_num1.setText(centerIndexBean.getHhp().getRp() + "");
                            tv_comment_type1.setText("红牌数");

                            piecolortv.setText(hongper + "%");
                            piecolortv.setTextColor(Color.parseColor("#DE463A"));
                            pjmctv.setText("红牌");
                            pjnumtv.setText(centerIndexBean.getHhp().getRp());
                        }

                    }
                }

                @Override
                public void onNothingSelected() {

                }
            });
            Legend legend = pieChart.getLegend();
            legend.setEnabled(false);
        }

        private void setPieDataGr(CenterIndexBean.HhvBean hhvBean) {

            ArrayList<PieEntry> entries = new ArrayList<PieEntry>();

            // NOTE: The order of the entries when being added to the entries array determines their position around the center of
            // the chart.

            entries.add(new PieEntry((float) (Integer.valueOf(hhvBean.getHp().getNum())),
                    mParties[0],
                    context.getResources().getDrawable(R.drawable.star)));

            entries.add(new PieEntry((float) (Integer.valueOf(hhvBean.getZp().getNum())),
                    mParties[1],
                    context.getResources().getDrawable(R.drawable.star)));

            entries.add(new PieEntry((float) (Integer.valueOf(hhvBean.getCp().getNum())),
                    mParties[2],
                    context.getResources().getDrawable(R.drawable.star)));


            PieDataSet dataSet = new PieDataSet(entries, "");

            dataSet.setDrawIcons(false);

            dataSet.setSliceSpace(3f);
            dataSet.setIconsOffset(new MPPointF(0, 40));
            dataSet.setSelectionShift(5f);

            ArrayList<Integer> colors = new ArrayList<Integer>();

            for (int c : VORDIPLOM_COLORS1)
                colors.add(c);

            dataSet.setColors(colors);
            PieData data = new PieData(dataSet);
            data.setValueFormatter(new PercentFormatter());
            data.setValueTextSize(11f);
            data.setValueTextColor(Color.WHITE);
            pieChart.setData(data);
            pieChart.highlightValues(null);
            for (IDataSet<?> set : pieChart.getData().getDataSets()) {
                set.setDrawValues(false);
            }

            pieChart.invalidate();
        }

        private void setPieDataCk(CenterIndexBean.HhpBean ckBeanList) {

            ArrayList<PieEntry> entries = new ArrayList<PieEntry>();

            // NOTE: The order of the entries when being added to the entries array determines their position around the center of
            // the chart.

            entries.add(new PieEntry((float) (Integer.valueOf(ckBeanList.getZc())),
                    mParties[0],
                    context.getResources().getDrawable(R.drawable.star)));

            entries.add(new PieEntry((float) (Integer.valueOf(ckBeanList.getHp())),
                    mParties[1],
                    context.getResources().getDrawable(R.drawable.star)));

            entries.add(new PieEntry((float) (Integer.valueOf(ckBeanList.getRp())),
                    mParties[2],
                    context.getResources().getDrawable(R.drawable.star)));


            PieDataSet dataSet = new PieDataSet(entries, "");

            dataSet.setDrawIcons(false);

            dataSet.setSliceSpace(3f);
            dataSet.setIconsOffset(new MPPointF(0, 40));
            dataSet.setSelectionShift(5f);

            ArrayList<Integer> colors = new ArrayList<Integer>();

            for (int c : VORDIPLOM_COLORS1)
                colors.add(c);

            dataSet.setColors(colors);
            PieData data = new PieData(dataSet);
            data.setValueFormatter(new PercentFormatter());
            data.setValueTextSize(11f);
            data.setValueTextColor(Color.WHITE);
            pieChart.setData(data);
            pieChart.highlightValues(null);
            for (IDataSet<?> set : pieChart.getData().getDataSets()) {
                set.setDrawValues(false);
            }

            pieChart.invalidate();
        }

        private void initLineChart(View view  , List<String> list) {
            lineChart = view.findViewById(R.id.lineChart);
            lineChart.getDescription().setEnabled(false);
            lineChart.setPinchZoom(false);
            lineChart.setDrawGridBackground(false);
            lineChart.getAxisRight().setEnabled(false);

            XAxis xAxis = lineChart.getXAxis();
            xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
            xAxis.setDrawGridLines(false);

            xAxis.setLabelCount(list.size(), true);

            xAxis.setValueFormatter(new ValueFormatter() {
                @Override
                public String getFormattedValue(float value) {
                    return String.valueOf((int) value + 1).concat("月");
                }
            });

            YAxis leftAxis = lineChart.getAxisLeft();
            leftAxis.setLabelCount(5);
            leftAxis.setAxisMaximum(100f);
            leftAxis.setAxisMinimum(0f);

            leftAxis.setValueFormatter(new ValueFormatter() {
                @Override
                public String getFormattedValue(float value) {
                    BigDecimal b = new BigDecimal(value);
                    value = b.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue();
                    return String.valueOf(value).concat("%");
                }
            });

            lineChart.getAxisLeft().setDrawGridLines(false);

            lineChart.getLegend().setEnabled(false);

            MyMarkerView mv = new MyMarkerView(context, R.layout.custom_marker_view);
            mv.setChartView(lineChart); // For bounds control
            lineChart.setMarker(mv);
        }

        private void initLineChart2(View view, List<String> list) {
            lineChart = view.findViewById(R.id.lineChart);
            lineChart.getDescription().setEnabled(false);
            lineChart.setPinchZoom(false);
            lineChart.setDrawGridBackground(false);
            lineChart.getAxisRight().setEnabled(false);

            XAxis xAxis = lineChart.getXAxis();
            xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
            xAxis.setDrawGridLines(false);

            xAxis.setLabelCount(list.size(), true);

            xAxis.setValueFormatter(new ValueFormatter() {
                @Override
                public String getFormattedValue(float value) {
                    return String.valueOf((int) value + 1).concat("月");
                }
            });

            YAxis leftAxis = lineChart.getAxisLeft();
            leftAxis.setLabelCount(5);
            leftAxis.setAxisMaximum(100f);
            leftAxis.setAxisMinimum(0f);

            leftAxis.setValueFormatter(new ValueFormatter() {
                @Override
                public String getFormattedValue(float value) {
                    BigDecimal b = new BigDecimal(value);
                    value = b.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue();
                    return String.valueOf(value).concat("%");
                }
            });

            lineChart.getAxisLeft().setDrawGridLines(false);

            lineChart.getLegend().setEnabled(false);

            MyMarkerView mv = new MyMarkerView(context, R.layout.custom_marker_view);
            mv.setChartView(lineChart); // For bounds control
            lineChart.setMarker(mv);
        }

        private void setLineData1(List<String> handle) {
            ArrayList<Entry> yVals = new ArrayList<Entry>();

            for (int i = 0; i < handle.size(); i++) {
                yVals.add(new Entry(i, Float.valueOf(handle.get(i)) * 100f));
            }

            LineDataSet set = new LineDataSet(yVals, "Data Set");
            set.setColors(ColorTemplate.VORDIPLOM_COLORS);
            set.setDrawValues(false);
            set.setDrawFilled(true);
            set.setHighlightEnabled(true);//是否禁用点击高亮线
            set.setHighLightColor(Color.RED);//设置点击交点后显示交高亮线的颜色
            Drawable drawable = ContextCompat.getDrawable(context, R.drawable.fade_linechart);
            set.setFillDrawable(drawable);


            LineData data = new LineData(set);

            lineChart.setData(data);
            lineChart.invalidate();
            lineChart.animateY(800);
        }


    }

    public class ViewHolder5 extends RecyclerView.ViewHolder {

        @Bind(R.id.tv_bad)
        TextView tvBad;
        @Bind(R.id.tv_color)
        TextView tvColor;
        @Bind(R.id.pieChart)
        PieChart pieChart;
        @Bind(R.id.tv_comment_type)
        TextView tvCommentType;
        @Bind(R.id.tv_comment_num)
        TextView tvCommentNum;
        @Bind(R.id.tv_comment_pertype)
        TextView tvCommentPertype;
        @Bind(R.id.tv_comment_per)
        TextView tvCommentPer;
        @Bind(R.id.tv_comment_type1)
        TextView tv_comment_type1;
        @Bind(R.id.tv_comment_num1)
        TextView tv_comment_num1;
        @Bind(R.id.rl_ll2)
        LinearLayout rl_ll2;
        @Bind(R.id.rl_ll1)
        LinearLayout rl_ll1;

        @Bind(R.id.piecolortv)
        TextView piecolortv;
        @Bind(R.id.pjmctv)
        TextView pjmctv;
        @Bind(R.id.pjnumtv)
        TextView pjnumtv;
        @Bind(R.id.tv_sj)
        TextView tv_sj;
        @Bind(R.id.tv_qs)
        TextView tv_qs;
        @Bind(R.id.lineChart)
        LineChart lineChart;
        @Bind(R.id.custom_text_tv)
        TextView custom_text_tv;

        public ViewHolder5(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }

        public void setData(final CenterIndexBean bean) {
            custom_text_tv.setText(bean.getCustom_text());
            tvColor.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    bean.setIshhl(false);
                    notifyItemChanged(4);
                }
            });

            tvBad.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    bean.setIshhl(true);
                    notifyItemChanged(4);
                }
            });


            initPieChart(bean);

//            initLineChart(lineChart);


            //加一个默认的状态
            tvCommentPer.setText(centerIndexBean.getHhv().getHp().getXs() + "");
            tvCommentType.setText("好评数");
            tvCommentPertype.setText("好评率");
            tvCommentPer.setTextColor(Color.parseColor("#4071FF"));
            tvCommentNum.setText(centerIndexBean.getHhv().getHp().getNum() + "");

            tv_comment_num1.setText(centerIndexBean.getHhp().getZc() + "");
            tv_comment_type1.setText("正常数");

            Integer zcint = Integer.valueOf(centerIndexBean.getHhp().getZc());
            Integer hongpaiint = Integer.valueOf(centerIndexBean.getHhp().getRp());
            Integer huangpaiint = Integer.valueOf(centerIndexBean.getHhp().getHp());

            int all = zcint + hongpaiint + huangpaiint;

            if (all == 0) {
                all = 1;
            }

            zcper = zcint * 100 / all;
            hongper = (float) hongpaiint * 100 / all;
            huangper = (float) huangpaiint * 100 / all;


            if (bean.isIshhl()) {
                tvColor.setBackgroundResource(R.drawable.shapef5);
                tvColor.setTextColor(Color.parseColor("#FF7D8198"));
                tvColor.getPaint().setFakeBoldText(false);
                tvBad.setBackgroundResource(R.drawable.shape1076ff);
                tvBad.setTextColor(Color.parseColor("#ffffff"));
                tvBad.getPaint().setFakeBoldText(true);
                setPieDataGr(bean.getHhv());
                rl_ll1.setVisibility(View.VISIBLE);
                rl_ll2.setVisibility(View.GONE);

                piecolortv.setText(centerIndexBean.getHhv().getHp().getXs());
                piecolortv.setTextColor(Color.parseColor("#4071FF"));
                pjmctv.setText("好评");
                pjnumtv.setText(centerIndexBean.getHhv().getHp().getNum() + "");
            } else {
                tvColor.setBackgroundResource(R.drawable.shape1076ff);
                tvColor.setTextColor(Color.parseColor("#ffffff"));
                tvColor.getPaint().setFakeBoldText(true);
                tvBad.setBackgroundResource(R.drawable.shapef5);
                tvBad.setTextColor(Color.parseColor("#FF7D8198"));
                tvBad.getPaint().setFakeBoldText(false);
                setPieDataCk(bean.getHhp());
                rl_ll1.setVisibility(View.GONE);
                rl_ll2.setVisibility(View.VISIBLE);

                piecolortv.setText(zcper + "%");
                piecolortv.setTextColor(Color.parseColor("#4071FF"));
                pjmctv.setText("正常");
                pjnumtv.setText(centerIndexBean.getHhp().getZc());
            }


        }

//        private Boolean isInCk = true;//当前状态是点击好坏率还是红黄牌

        private void initPieChart(final CenterIndexBean centerIndexBean) {

            pieChart.setUsePercentValues(true);
            pieChart.getDescription().setEnabled(false);
            pieChart.setExtraOffsets(0, 0, 0, 0);
            pieChart.setCenterText("");//中间的文字
            pieChart.setDrawHoleEnabled(true);//中间的洞
            pieChart.setHoleColor(Color.WHITE);
            pieChart.setTransparentCircleColor(Color.WHITE);
            pieChart.setTransparentCircleAlpha(110);
            pieChart.setHoleRadius(78f);
            pieChart.setTransparentCircleRadius(61f);
            pieChart.setDrawCenterText(true);//是否显示中间文字
            pieChart.setRotationAngle(0);
            pieChart.setDrawSliceText(false);//是否显示文字
            pieChart.setRotationEnabled(true);
            pieChart.setHighlightPerTapEnabled(true);
            pieChart.setOnChartValueSelectedListener(new OnChartValueSelectedListener() {
                @Override
                public void onValueSelected(Entry e, Highlight h) {

                    int x = (int) h.getX();

                    if (centerIndexBean.isIshhl()) {
                        //好评率
                        if (x == 0) {
                            tvCommentPer.setText(centerIndexBean.getHhv().getHp().getXs() + "");
                            tvCommentType.setText("好评数");
                            tvCommentPertype.setText("好评率");
                            tvCommentPer.setTextColor(Color.parseColor("#4071FF"));
                            tvCommentNum.setText(centerIndexBean.getHhv().getHp().getNum() + "");

                            piecolortv.setText(centerIndexBean.getHhv().getHp().getXs());
                            piecolortv.setTextColor(Color.parseColor("#4071FF"));
                            pjmctv.setText("好评");
                            pjnumtv.setText(centerIndexBean.getHhv().getHp().getNum() + "");
                        } else if (x == 1) {
                            tvCommentPer.setText(centerIndexBean.getHhv().getZp().getXs() + "");
                            tvCommentType.setText("中评数");
                            tvCommentPertype.setText("中评率");
                            tvCommentPer.setTextColor(Color.parseColor("#F8AF35"));
                            tvCommentNum.setText(centerIndexBean.getHhv().getZp().getNum() + "");

                            piecolortv.setText(centerIndexBean.getHhv().getZp().getXs());
                            piecolortv.setTextColor(Color.parseColor("#F8AF35"));
                            pjmctv.setText("中评");
                            pjnumtv.setText(centerIndexBean.getHhv().getZp().getNum() + "");
                        } else {
                            tvCommentPer.setText(centerIndexBean.getHhv().getCp().getXs() + "");
                            tvCommentType.setText("差评数");
                            tvCommentPertype.setText("差评率");
                            tvCommentPer.setTextColor(Color.parseColor("#DE463A"));
                            tvCommentNum.setText(centerIndexBean.getHhv().getCp().getNum() + "");

                            piecolortv.setText(centerIndexBean.getHhv().getCp().getXs());
                            piecolortv.setTextColor(Color.parseColor("#DE463A"));
                            pjmctv.setText("差评");
                            pjnumtv.setText(centerIndexBean.getHhv().getCp().getNum() + "");
                        }
                    } else {
                        //红黄牌
                        if (x == 0) {
                            tv_comment_num1.setText(centerIndexBean.getHhp().getZc() + "");
                            tv_comment_type1.setText("正常数");

                            piecolortv.setText(zcper + "%");
                            piecolortv.setTextColor(Color.parseColor("#4071FF"));
                            pjmctv.setText("正常");
                            pjnumtv.setText(centerIndexBean.getHhp().getZc());

                        } else if (x == 1) {
                            tv_comment_num1.setText(centerIndexBean.getHhp().getHp() + "");
                            tv_comment_type1.setText("黄牌数");
                            BigDecimal b = new BigDecimal(huangper);
                            piecolortv.setText(b.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue() + "%");
                            piecolortv.setTextColor(Color.parseColor("#F8AF35"));
                            pjmctv.setText("黄牌");
                            pjnumtv.setText(centerIndexBean.getHhp().getHp());
                        } else {
                            tv_comment_num1.setText(centerIndexBean.getHhp().getRp() + "");
                            tv_comment_type1.setText("红牌数");

                            BigDecimal b = new BigDecimal(hongper);
                            piecolortv.setText(b.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue() + "%");
                            piecolortv.setTextColor(Color.parseColor("#DE463A"));
                            pjmctv.setText("红牌");
                            pjnumtv.setText(centerIndexBean.getHhp().getRp());
                        }

                    }
                }

                @Override
                public void onNothingSelected() {

                }
            });
            Legend legend = pieChart.getLegend();
            legend.setEnabled(false);
        }


        private void setPieDataGr(CenterIndexBean.HhvBean hhvBean) {

            ArrayList<PieEntry> entries = new ArrayList<PieEntry>();

            // NOTE: The order of the entries when being added to the entries array determines their position around the center of
            // the chart.

            entries.add(new PieEntry((float) (Integer.valueOf(hhvBean.getHp().getNum())),
                    mParties[0],
                    context.getResources().getDrawable(R.drawable.star)));

            if ( Integer.valueOf(Integer.valueOf(hhvBean.getZp().getNum())) == 0){
                entries.add(new PieEntry((float) (0),
                        mParties[1],
                        context.getResources().getDrawable(R.drawable.star)));
            }

            if (Integer.valueOf(Integer.valueOf(hhvBean.getZp().getNum())) < 100 &&
                    Integer.valueOf(Integer.valueOf(hhvBean.getZp().getNum())) > 0) {
                entries.add(new PieEntry((float) (100),
                        mParties[1],
                        context.getResources().getDrawable(R.drawable.star)));
            }


            if (Integer.valueOf(Integer.valueOf(hhvBean.getZp().getNum())) >= 100) {
                entries.add(new PieEntry((float) (Integer.valueOf(hhvBean.getZp().getNum())),
                        mParties[1],
                        context.getResources().getDrawable(R.drawable.star)));
            }

            if (Integer.valueOf(Integer.valueOf(hhvBean.getCp().getNum())) == 0) {
                entries.add(new PieEntry((float) (0),
                        mParties[2],
                        context.getResources().getDrawable(R.drawable.star)));
            }

            if (Integer.valueOf(Integer.valueOf(hhvBean.getCp().getNum())) < 100
                    && Integer.valueOf(hhvBean.getCp().getNum()) > 0) {
                entries.add(new PieEntry((float) (100),
                        mParties[2],
                        context.getResources().getDrawable(R.drawable.star)));
            }

            if (Integer.valueOf(Integer.valueOf(hhvBean.getCp().getNum())) >= 100) {
                entries.add(new PieEntry((float) (Integer.valueOf(hhvBean.getCp().getNum())),
                        mParties[2],
                        context.getResources().getDrawable(R.drawable.star)));
            }


            PieDataSet dataSet = new PieDataSet(entries, "");

            dataSet.setDrawIcons(false);

            dataSet.setSliceSpace(3f);
            dataSet.setIconsOffset(new MPPointF(0, 40));
            dataSet.setSelectionShift(5f);

            ArrayList<Integer> colors = new ArrayList<Integer>();

            for (int c : VORDIPLOM_COLORS1)
                colors.add(c);

            dataSet.setColors(colors);
            PieData data = new PieData(dataSet);
            data.setValueFormatter(new PercentFormatter());
            data.setValueTextSize(11f);
            data.setValueTextColor(Color.WHITE);
            pieChart.setData(data);
            pieChart.highlightValues(null);
            for (IDataSet<?> set : pieChart.getData().getDataSets()) {
                set.setDrawValues(false);
            }

            pieChart.invalidate();
        }

        private void setPieDataCk(CenterIndexBean.HhpBean ckBeanList) {

            ArrayList<PieEntry> entries = new ArrayList<PieEntry>();

            // NOTE: The order of the entries when being added to the entries array determines their position around the center of
            // the chart.

            entries.add(new PieEntry((float) (Integer.valueOf(ckBeanList.getZc())),
                    mParties[0],
                    context.getResources().getDrawable(R.drawable.star)));

            if ( Integer.valueOf(ckBeanList.getHp()) == 0){
                entries.add(new PieEntry((float) (0),
                        mParties[1],
                        context.getResources().getDrawable(R.drawable.star)));
            }

            if (Integer.valueOf(ckBeanList.getHp()) < 600 && Integer.valueOf(ckBeanList.getHp()) > 0) {
                entries.add(new PieEntry((float) (600),
                        mParties[1],
                        context.getResources().getDrawable(R.drawable.star)));
            }


            if (Integer.valueOf(ckBeanList.getHp()) >= 600) {
                entries.add(new PieEntry((float) (Integer.valueOf(ckBeanList.getHp())),
                        mParties[1],
                        context.getResources().getDrawable(R.drawable.star)));
            }

            if (Integer.valueOf(ckBeanList.getRp()) == 0) {
                entries.add(new PieEntry((float) (0),
                        mParties[1],
                        context.getResources().getDrawable(R.drawable.star)));
            }

            if (Integer.valueOf(ckBeanList.getRp()) < 600 && Integer.valueOf(ckBeanList.getRp()) > 0) {
                entries.add(new PieEntry((float) (600),
                        mParties[1],
                        context.getResources().getDrawable(R.drawable.star)));
            }

            if (Integer.valueOf(ckBeanList.getRp()) >= 600) {
                entries.add(new PieEntry((float) (Integer.valueOf(ckBeanList.getRp())),
                        mParties[1],
                        context.getResources().getDrawable(R.drawable.star)));
            }


            PieDataSet dataSet = new PieDataSet(entries, "");

            dataSet.setDrawIcons(false);

            dataSet.setSliceSpace(3f);
            dataSet.setIconsOffset(new MPPointF(0, 40));
            dataSet.setSelectionShift(5f);

            ArrayList<Integer> colors = new ArrayList<Integer>();

            for (int c : VORDIPLOM_COLORS1)
                colors.add(c);

            dataSet.setColors(colors);
            PieData data = new PieData(dataSet);
            data.setValueFormatter(new PercentFormatter());
            data.setValueTextSize(11f);
            data.setValueTextColor(Color.WHITE);
            pieChart.setData(data);
            pieChart.highlightValues(null);
            for (IDataSet<?> set : pieChart.getData().getDataSets()) {
                set.setDrawValues(false);
            }

            pieChart.invalidate();
        }

        private void initLineChart(View view) {
            lineChart = view.findViewById(R.id.lineChart);
            lineChart.getDescription().setEnabled(false);
            lineChart.setPinchZoom(false);
            lineChart.setDrawGridBackground(false);
            lineChart.getAxisRight().setEnabled(false);

            XAxis xAxis = lineChart.getXAxis();
            xAxis.setPosition(XAxis.XAxisPosition.BOTTOM);
            xAxis.setDrawGridLines(false);

            xAxis.setLabelCount(12, true);

            xAxis.setValueFormatter(new ValueFormatter() {
                @Override
                public String getFormattedValue(float value) {
                    return String.valueOf((int) value + 1).concat("月");
                }
            });

            YAxis leftAxis = lineChart.getAxisLeft();
            leftAxis.setLabelCount(5);
            leftAxis.setAxisMaximum(100f);
            leftAxis.setAxisMinimum(0f);

            leftAxis.setValueFormatter(new ValueFormatter() {
                @Override
                public String getFormattedValue(float value) {
                    BigDecimal b = new BigDecimal(value);
                    value = b.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue();
                    return String.valueOf(value).concat("%");
                }
            });

            lineChart.getAxisLeft().setDrawGridLines(false);

            lineChart.getLegend().setEnabled(false);

            MyMarkerView mv = new MyMarkerView(context, R.layout.custom_marker_view);
            mv.setChartView(lineChart); // For bounds control
            lineChart.setMarker(mv);
        }

        private void setLineData1(List<String> handle) {
            ArrayList<Entry> yVals = new ArrayList<Entry>();

            for (int i = 0; i < handle.size(); i++) {
                yVals.add(new Entry(i, Float.valueOf(handle.get(i)) * 100f));
            }

            LineDataSet set = new LineDataSet(yVals, "Data Set");
            set.setColors(ColorTemplate.VORDIPLOM_COLORS);
            set.setDrawValues(false);
            set.setDrawFilled(true);
            set.setHighlightEnabled(true);//是否禁用点击高亮线
            set.setHighLightColor(Color.RED);//设置点击交点后显示交高亮线的颜色
            Drawable drawable = ContextCompat.getDrawable(context, R.drawable.fade_linechart);
            set.setFillDrawable(drawable);


            LineData data = new LineData(set);

            lineChart.setData(data);
            lineChart.invalidate();
            lineChart.animateY(800);
        }


    }

    public interface Dklistener {
        public void dk();
    }


}
